package me.xue.communityhealth.repo;

import me.xue.communityhealth.model.Registration;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface RegistrationRepository {

    @Insert("INSERT INTO `registration`(name,cost) VALUES(#{name},#{cost})")
    int insert(Registration registration);

    @Update("UPDATE `registration` SET `name`=#{name},`cost`=#{cost} WHERE `id`=#{id}")
    int update(Registration registration);

    @Delete("DELETE FROM `registration` WHERE `id`=#{id}")
    int delete(int id);

    @Select("SELECT * FROM `registration` WHERE `name`=#{name} ORDER BY `id` LIMIT 1")
    Registration findByName(String name);

    @Select("SELECT * FROM `registration` WHERE `name`=#{name}")
    List<Registration> findAllByName(String name);

    @Select("SELECT * FROM `registration`")
    List<Registration> findAll();

}
